package com.own.business.system.user.wechat.core.method;

import com.own.business.system.account.business.service.SystemAccountService;
import com.own.business.system.account.common.base.BaseAccountType;
import com.own.business.system.account.common.hook.AccountHook;
import com.own.business.system.user.wechat.core.type.AccountType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * SystemUserWechatMethodHook
 *
 * @author chenxueli
 * @date 2023-06-30 11:35:44
 */
@Slf4j
@Component
public class SystemUserWechatMethodHook implements AccountHook {

    @Resource
    private SystemAccountService systemAccountService;

    /**
     * 添加账号信息
     *
     * @param account     账号
     * @param userId      用户id
     * @param accountType 账号类型 1=普通用户 2=管理员
     * @param password    密码（未加密）
     */
    @Override
    public void add(String account, Long userId, int accountType, String password) {
        systemAccountService.save(account, null, type(), accountType, userId);
    }

    /**
     * 账号的类型
     *
     * @return 账号的类型
     */
    @Override
    public BaseAccountType type() {
        return AccountType.WECHAT;
    }

}
